package dao

import (
	"server/basic/config"
	"server/basic/model"
	"server/basic/proto/order"
)

func OrderAdd(req *order.OrderAddReq) (order model.Orders, err error) {
	order = model.Orders{
		DoctorId:      int64(req.DoctorId),
		UserId:        req.UserId,
		OrderType:     req.OrderType,
		PaymentType:   req.PaymentType,
		OrderMoney:    float64(req.OrderMoney),
		RegisterId:    int64(req.RegisterId),
		ThePatientsId: int64(req.ThePatientsId),
	}
	err = config.DB.Create(&order).Error
	if err != nil {
		return model.Orders{}, err
	}
	return order, nil
}
